package com.ly.sky.controller;

import com.ly.sky.util.RedisUtils;
import org.apache.skywalking.apm.toolkit.trace.TraceContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collections;

/**
 * @Author LY
 * @create 2023/11/7 14:42
 * @Description 测试控制层
 */
@RestController
public class SkyController {

    @Autowired
    private RedisUtils redisUtils;

    private static Logger logger = LoggerFactory.getLogger(SkyController.class);

    @GetMapping("/printLog")
    public String printLog() {
        logger.info("printLog:traceId:{}", TraceContext.traceId());
        redisUtils.add("123456", Collections.singleton("123456"));
        return "ok";
    }

    @GetMapping("/getStr")
    public String getStr() {
        logger.info("getStr:traceId:{}", TraceContext.traceId());
        return "ok" + redisUtils.get("123456");
    }

    @GetMapping("/getStr2")
    public String getStr2() {
        return "ok:getStr2";
    }
}
